﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Components
{
    public partial class VirtualKeybaoard : UserControl
    {
        public bool ShiftDown = false;
        public bool CapsDown = false;
        private Bitmap DrawingArea;
        private FlatStyle buttonStyle;
        private Color buttonForeColor;
        private Color buttonBackColor;
        private Font buttonFont;
        private ContentAlignment buttonTextAlign;

        public Color ButtonBackColor
        {
            get
            {
                return buttonBackColor;
            }
            set
            {
                buttonBackColor = value;
                setButtonBackColor(buttonBackColor);
            }
        }

        public Color ButtonForeColor
        {
            get
            {
                return buttonForeColor;
            }
            set
            {
                buttonForeColor = value;
                setButtonForeColor(buttonForeColor);
            }
        }

        public FlatStyle ButtonStyle
        {
            get
            {
                return buttonStyle;
            }
            set
            {
                buttonStyle = value;
                setButtonFlatStyle(buttonStyle);
            }
        }

        public Font ButtonFont
        {
            get
            {
                return buttonFont;
            }
            set
            {
                buttonFont = value;
                setButtonFont(buttonFont);
            }
        }

        public ContentAlignment ButtonTextAlign
        {
            get
            {
                return buttonTextAlign;
            }
            set
            {
                buttonTextAlign = value;
                setTextAlign(buttonTextAlign);
            }
        }

        private void setButtonForeColor(Color newColor)
        {
            console.ForeColor = newColor;
            one.ForeColor = newColor;
            two.ForeColor = newColor;
            three.ForeColor = newColor;
            four.ForeColor = newColor;
            five.ForeColor = newColor;
            six.ForeColor = newColor;
            seven.ForeColor = newColor;
            eight.ForeColor = newColor;
            nine.ForeColor = newColor;
            zero.ForeColor = newColor;
            subtract.ForeColor = newColor;
            equals.ForeColor = newColor;
            q.ForeColor = newColor;
            w.ForeColor = newColor;
            e.ForeColor = newColor;
            r.ForeColor = newColor;
            t.ForeColor = newColor;
            y.ForeColor = newColor;
            u.ForeColor = newColor;
            i.ForeColor = newColor;
            o.ForeColor = newColor;
            p.ForeColor = newColor;
            openBrackets.ForeColor = newColor;
            closingBrackets.ForeColor = newColor;
            backslash.ForeColor = newColor;
            a.ForeColor = newColor;
            s.ForeColor = newColor;
            d.ForeColor = newColor;
            f.ForeColor = newColor;
            g.ForeColor = newColor;
            h.ForeColor = newColor;
            j.ForeColor = newColor;
            k.ForeColor = newColor;
            l.ForeColor = newColor;
            semiColon.ForeColor = newColor;
            apostrophe.ForeColor = newColor;
            z.ForeColor = newColor;
            x.ForeColor = newColor;
            c.ForeColor = newColor;
            v.ForeColor = newColor;
            b.ForeColor = newColor;
            n.ForeColor = newColor;
            m.ForeColor = newColor;
            comma.ForeColor = newColor;
            period.ForeColor = newColor;
            forewardSlash.ForeColor = newColor;
            tab.ForeColor = newColor;
            caps.ForeColor = newColor;
            shift.ForeColor = newColor;
            space.ForeColor = newColor;
            upArrow.ForeColor = newColor;
            leftArrow.ForeColor = newColor;
            downArrow.ForeColor = newColor;
            rightArrow.ForeColor = newColor;
            enter.ForeColor = newColor;
            backspace.ForeColor = newColor;
        }

        private void setButtonBackColor(Color newColor)
        {
            console.BackColor = newColor;
            one.BackColor = newColor;
            two.BackColor = newColor;
            three.BackColor = newColor;
            four.BackColor = newColor;
            five.BackColor = newColor;
            six.BackColor = newColor;
            seven.BackColor = newColor;
            eight.BackColor = newColor;
            nine.BackColor = newColor;
            zero.BackColor = newColor;
            subtract.BackColor = newColor;
            equals.BackColor = newColor;
            q.BackColor = newColor;
            w.BackColor = newColor;
            e.BackColor = newColor;
            r.BackColor = newColor;
            t.BackColor = newColor;
            y.BackColor = newColor;
            u.BackColor = newColor;
            i.BackColor = newColor;
            o.BackColor = newColor;
            p.BackColor = newColor;
            openBrackets.BackColor = newColor;
            closingBrackets.BackColor = newColor;
            backslash.BackColor = newColor;
            a.BackColor = newColor;
            s.BackColor = newColor;
            d.BackColor = newColor;
            f.BackColor = newColor;
            g.BackColor = newColor;
            h.BackColor = newColor;
            j.BackColor = newColor;
            k.BackColor = newColor;
            l.BackColor = newColor;
            semiColon.BackColor = newColor;
            apostrophe.BackColor = newColor;
            z.BackColor = newColor;
            x.BackColor = newColor;
            c.BackColor = newColor;
            v.BackColor = newColor;
            b.BackColor = newColor;
            n.BackColor = newColor;
            m.BackColor = newColor;
            comma.BackColor = newColor;
            period.BackColor = newColor;
            forewardSlash.BackColor = newColor;
            tab.BackColor = newColor;
            caps.BackColor = newColor;
            shift.BackColor = newColor;
            space.BackColor = newColor;
            upArrow.BackColor = newColor;
            leftArrow.BackColor = newColor;
            downArrow.BackColor = newColor;
            rightArrow.BackColor = newColor;
            enter.BackColor = newColor;
            backspace.BackColor = newColor;
        }

        private void setButtonFlatStyle(FlatStyle flatStyle)
        {
            console.FlatStyle = flatStyle;
            one.FlatStyle = flatStyle;
            two.FlatStyle = flatStyle;
            three.FlatStyle = flatStyle;
            four.FlatStyle = flatStyle;
            five.FlatStyle = flatStyle;
            six.FlatStyle = flatStyle;
            seven.FlatStyle = flatStyle;
            eight.FlatStyle = flatStyle;
            nine.FlatStyle = flatStyle;
            zero.FlatStyle = flatStyle;
            subtract.FlatStyle = flatStyle;
            equals.FlatStyle = flatStyle;
            q.FlatStyle = flatStyle;
            w.FlatStyle = flatStyle;
            e.FlatStyle = flatStyle;
            r.FlatStyle = flatStyle;
            t.FlatStyle = flatStyle;
            y.FlatStyle = flatStyle;
            u.FlatStyle = flatStyle;
            i.FlatStyle = flatStyle;
            o.FlatStyle = flatStyle;
            p.FlatStyle = flatStyle;
            openBrackets.FlatStyle = flatStyle;
            closingBrackets.FlatStyle = flatStyle;
            backslash.FlatStyle = flatStyle;
            a.FlatStyle = flatStyle;
            s.FlatStyle = flatStyle;
            d.FlatStyle = flatStyle;
            f.FlatStyle = flatStyle;
            g.FlatStyle = flatStyle;
            h.FlatStyle = flatStyle;
            j.FlatStyle = flatStyle;
            k.FlatStyle = flatStyle;
            l.FlatStyle = flatStyle;
            semiColon.FlatStyle = flatStyle;
            apostrophe.FlatStyle = flatStyle;
            z.FlatStyle = flatStyle;
            x.FlatStyle = flatStyle;
            c.FlatStyle = flatStyle;
            v.FlatStyle = flatStyle;
            b.FlatStyle = flatStyle;
            n.FlatStyle = flatStyle;
            m.FlatStyle = flatStyle;
            comma.FlatStyle = flatStyle;
            period.FlatStyle = flatStyle;
            forewardSlash.FlatStyle = flatStyle;
            tab.FlatStyle = flatStyle;
            caps.FlatStyle = flatStyle;
            shift.FlatStyle = flatStyle;
            space.FlatStyle = flatStyle;
            upArrow.FlatStyle = flatStyle;
            leftArrow.FlatStyle = flatStyle;
            downArrow.FlatStyle = flatStyle;
            rightArrow.FlatStyle = flatStyle;
            enter.FlatStyle = flatStyle;
            backspace.FlatStyle = flatStyle;
        }

        private void setButtonFont(Font font)
        {
            console.Font = font;
            one.Font = font;
            two.Font = font;
            three.Font = font;
            four.Font = font;
            five.Font = font;
            six.Font = font;
            seven.Font = font;
            eight.Font = font;
            nine.Font = font;
            zero.Font = font;
            subtract.Font = font;
            equals.Font = font;
            q.Font = font;
            w.Font = font;
            e.Font = font;
            r.Font = font;
            t.Font = font;
            y.Font = font;
            u.Font = font;
            i.Font = font;
            o.Font = font;
            p.Font = font;
            openBrackets.Font = font;
            closingBrackets.Font = font;
            backslash.Font = font;
            a.Font = font;
            s.Font = font;
            d.Font = font;
            f.Font = font;
            g.Font = font;
            h.Font = font;
            j.Font = font;
            k.Font = font;
            l.Font = font;
            semiColon.Font = font;
            apostrophe.Font = font;
            z.Font = font;
            x.Font = font;
            c.Font = font;
            v.Font = font;
            b.Font = font;
            n.Font = font;
            m.Font = font;
            comma.Font = font;
            period.Font = font;
            forewardSlash.Font = font;
            tab.Font = font;
            caps.Font = font;
            shift.Font = font;
            space.Font = font;
            upArrow.Font = font;
            leftArrow.Font = font;
            downArrow.Font = font;
            rightArrow.Font = font;
            enter.Font = font;
            backspace.Font = font;
        }

        private void setTextAlign(ContentAlignment textAlign)
        {
            console.TextAlign = textAlign;
            one.TextAlign = textAlign;
            two.TextAlign = textAlign;
            three.TextAlign = textAlign;
            four.TextAlign = textAlign;
            five.TextAlign = textAlign;
            six.TextAlign = textAlign;
            seven.TextAlign = textAlign;
            eight.TextAlign = textAlign;
            nine.TextAlign = textAlign;
            zero.TextAlign = textAlign;
            subtract.TextAlign = textAlign;
            equals.TextAlign = textAlign;
            q.TextAlign = textAlign;
            w.TextAlign = textAlign;
            e.TextAlign = textAlign;
            r.TextAlign = textAlign;
            t.TextAlign = textAlign;
            y.TextAlign = textAlign;
            u.TextAlign = textAlign;
            i.TextAlign = textAlign;
            o.TextAlign = textAlign;
            p.TextAlign = textAlign;
            openBrackets.TextAlign = textAlign;
            closingBrackets.TextAlign = textAlign;
            backslash.TextAlign = textAlign;
            a.TextAlign = textAlign;
            s.TextAlign = textAlign;
            d.TextAlign = textAlign;
            f.TextAlign = textAlign;
            g.TextAlign = textAlign;
            h.TextAlign = textAlign;
            j.TextAlign = textAlign;
            k.TextAlign = textAlign;
            l.TextAlign = textAlign;
            semiColon.TextAlign = textAlign;
            apostrophe.TextAlign = textAlign;
            z.TextAlign = textAlign;
            x.TextAlign = textAlign;
            c.TextAlign = textAlign;
            v.TextAlign = textAlign;
            b.TextAlign = textAlign;
            n.TextAlign = textAlign;
            m.TextAlign = textAlign;
            comma.TextAlign = textAlign;
            period.TextAlign = textAlign;
            forewardSlash.TextAlign = textAlign;
            tab.TextAlign = textAlign;
            caps.TextAlign = textAlign;
            shift.TextAlign = textAlign;
            space.TextAlign = textAlign;
            upArrow.TextAlign = textAlign;
            leftArrow.TextAlign = textAlign;
            downArrow.TextAlign = textAlign;
            rightArrow.TextAlign = textAlign;
            enter.TextAlign = textAlign;
            backspace.TextAlign = textAlign;
        }

        public VirtualKeybaoard()
        {
            InitializeComponent();
        }

        private void VirtualKeybaoard_Load(object sender, EventArgs e)
        {
            DrawingArea = new Bitmap(
                    this.ClientRectangle.Width,
                    this.ClientRectangle.Height,
                    System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            using (var canvas = Graphics.FromImage(DrawingArea))
            {
                canvas.Clear(Color.Transparent);
                canvas.FillPolygon(Brushes.Black, new PointF[] { new PointF(10, 10), new PointF(0, 0), new PointF(0, 10) });
            }
            this.Invalidate();
        }

        private void VirtualKeybaoard_Resize(object sender, EventArgs ea)
        {/*
            short width1and2Row = (short)(this.Width / 14);
            short widthRemain1and2Row = (short)(this.Width % 14);
            short width3Row = (short)(this.Width / 13);
            short widthRemain3Row = (short)(this.Width % 13);
            short width4Row = (short)(this.Width / 11);
            short widthRemain4Row = (short)(this.Width % 11);

            tab.Width = (int)(width1and2Row * 1.375);
            backspace.Width = (int)(width1and2Row * 1.825);
            backslash.Width = (int)(width1and2Row * 1.45);
            caps.Width = (int)(width3Row * 1.65);
            enter.Width = (int)(width3Row * 2.325);
            shift.Width = (int)(width4Row * 2.075);
            one.Width = width1and2Row;
            two.Width = width1and2Row;
            three.Width = width1and2Row;
            four.Width = width1and2Row;
            console.Width = width1and2Row;
            five.Width = width1and2Row;
            six.Width = width1and2Row;
            seven.Width = width1and2Row;
            eight.Width = width1and2Row;
            nine.Width = width1and2Row;
            zero.Width = width1and2Row;
            subtract.Width = width1and2Row;
            equals.Width = width1and2Row;

            one.Location = new Point(console.Location.X + console.Width + 5, one.Location.Y);
            two.Location = new Point(one.Location.X + one.Width + 5, two.Location.Y);
            three.Location = new Point(two.Location.X + two.Width + 5, three.Location.Y);
            four.Location = new Point(three.Location.X + three.Width + 5, four.Location.Y);
            five.Location = new Point(four.Location.X + four.Width + 5, four.Location.Y);
            six.Location = new Point(five.Location.X + five.Width + 5, six.Location.Y);
            seven.Location = new Point(six.Location.X + six.Width + 5, seven.Location.Y);
            eight.Location = new Point(seven.Location.X + seven.Width + 5, eight.Location.Y);
            nine.Location = new Point(eight.Location.X + eight.Width + 5, nine.Location.Y);
            zero.Location = new Point(nine.Location.X + nine.Width + 5, zero.Location.Y);
            subtract.Location = new Point(zero.Location.X + zero.Width + 5, subtract.Location.Y);
            equals.Location = new Point(subtract.Location.X + subtract.Width + 5, equals.Location.Y);
            backspace.Location = new Point(equals.Location.X + equals.Width + 5, backspace.Location.Y);*/
        }

        private void Form1_Click(object sender, EventArgs e)
        {

        }

        private void console_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("{~}");
                FromShift();
            }
            else
            {
                SendKeys.Send("`");
            }
        }

        private void one_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("!");
                FromShift();
            }
            else
            {
                SendKeys.Send("1");
            }
        }

        private void two_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("@");
                FromShift();
            }
            else
            {
                SendKeys.Send("2");
            }
        }

        private void three_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("#");
                FromShift();
            }
            else
            {
                SendKeys.Send("3");
            }
        }

        private void four_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("$");
                FromShift();
            }
            else
            {
                SendKeys.Send("4");
            }
        }

        private void five_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("{%}");
                FromShift();
            }
            else
            {
                SendKeys.Send("5");
            }
        }

        private void six_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("{^}");
                FromShift();
            }
            else
            {
                SendKeys.Send("6");
            }
        }

        private void seven_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("&");
                FromShift();
            }
            else
            {
                SendKeys.Send("7");
            }
        }

        private void shift_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                FromShift();
            }
            else
            {
                ToShift();
            }
        }

        private void ToShift()
        {
            console.Text = "~";
            one.Text = "!";
            two.Text = "@";
            three.Text = "#";
            four.Text = "$";
            five.Text = "%";
            six.Text = "^";
            seven.Text = "&&";
            eight.Text = "*";
            nine.Text = "(";
            zero.Text = ")";
            subtract.Text = "_";
            equals.Text = "+";
            q.Text = "Q";
            w.Text = "W";
            e.Text = "E";
            r.Text = "R";
            t.Text = "T";
            y.Text = "Y";
            u.Text = "U";
            i.Text = "I";
            o.Text = "O";
            p.Text = "P";
            openBrackets.Text = "{";
            closingBrackets.Text = "}";
            backslash.Text = "|";
            a.Text = "A";
            s.Text = "S";
            d.Text = "D";
            f.Text = "F";
            g.Text = "G";
            h.Text = "H";
            j.Text = "J";
            k.Text = "K";
            l.Text = "L";
            semiColon.Text = ":";
            apostrophe.Text = "\"";
            z.Text = "Z";
            x.Text = "X";
            c.Text = "C";
            v.Text = "V";
            b.Text = "B";
            n.Text = "N";
            m.Text = "M";
            comma.Text = "<";
            period.Text = ">";
            forewardSlash.Text = "?";
            ShiftDown = true;
            shift.BackColor = Color.FromArgb(200, 200, 200);
        }

        private void FromShift()
        {
            console.Text = "`";
            one.Text = "1";
            two.Text = "2";
            three.Text = "3";
            four.Text = "4";
            five.Text = "5";
            six.Text = "6";
            seven.Text = "7";
            eight.Text = "8";
            nine.Text = "9";
            zero.Text = "0";
            subtract.Text = "-";
            equals.Text = "=";
            q.Text = "q";
            w.Text = "w";
            e.Text = "e";
            r.Text = "r";
            t.Text = "t";
            y.Text = "y";
            u.Text = "u";
            i.Text = "i";
            o.Text = "o";
            p.Text = "p";
            openBrackets.Text = "[";
            closingBrackets.Text = "]";
            backslash.Text = "\\";
            a.Text = "a";
            s.Text = "s";
            d.Text = "d";
            f.Text = "f";
            g.Text = "g";
            h.Text = "h";
            j.Text = "j";
            k.Text = "k";
            l.Text = "l";
            semiColon.Text = ";";
            apostrophe.Text = "'";
            z.Text = "z";
            x.Text = "x";
            c.Text = "c";
            v.Text = "v";
            b.Text = "b";
            n.Text = "n";
            m.Text = "m";
            comma.Text = ",";
            period.Text = ".";
            forewardSlash.Text = "/";
            ShiftDown = false;
            shift.BackColor = Color.FromArgb(240, 240, 240);
        }

        private void ToCaps()
        {
            q.Text = "Q";
            w.Text = "W";
            e.Text = "E";
            r.Text = "R";
            t.Text = "T";
            y.Text = "Y";
            u.Text = "U";
            i.Text = "I";
            o.Text = "O";
            p.Text = "P";
            a.Text = "A";
            s.Text = "S";
            d.Text = "D";
            f.Text = "F";
            g.Text = "G";
            h.Text = "H";
            j.Text = "J";
            k.Text = "K";
            l.Text = "L";
            z.Text = "Z";
            x.Text = "X";
            c.Text = "C";
            v.Text = "V";
            b.Text = "B";
            n.Text = "N";
            m.Text = "M";
            CapsDown = true;
            caps.BackColor = Color.FromArgb(200, 200, 200);
        }

        private void FromCaps()
        {
            q.Text = "q";
            w.Text = "w";
            e.Text = "e";
            r.Text = "r";
            t.Text = "t";
            y.Text = "y";
            u.Text = "u";
            i.Text = "i";
            o.Text = "o";
            p.Text = "p";
            a.Text = "a";
            s.Text = "s";
            d.Text = "d";
            f.Text = "f";
            g.Text = "g";
            h.Text = "h";
            j.Text = "j";
            k.Text = "k";
            l.Text = "l";
            z.Text = "z";
            x.Text = "x";
            c.Text = "c";
            v.Text = "v";
            b.Text = "b";
            n.Text = "n";
            m.Text = "m";
            CapsDown = false;
            caps.BackColor = Color.FromArgb(240, 240, 240);
        }

        private void eight_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("*");
                FromShift();
            }
            else
            {
                SendKeys.Send("8");
            }
        }

        private void nine_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("(");
                FromShift();
            }
            else
            {
                SendKeys.Send("9");
            }
        }

        private void zero_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send(")");
                FromShift();
            }
            else
            {
                SendKeys.Send("0");
            }
        }

        private void subtract_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("_");
                FromShift();
            }
            else
            {
                SendKeys.Send("-");
            }
        }

        private void equals_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("{+}");
                FromShift();
            }
            else
            {
                SendKeys.Send("=");
            }
        }

        private void backspace_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{BS}");
        }

        private void tab_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{TAB}");
        }

        private void q_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("q");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("Q");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("Q");
            }
            else
            {
                SendKeys.Send("q");
            }
        }

        private void caps_Click(object sender, EventArgs e)
        {
            if (CapsDown)
            {
                FromCaps();
            }
            else
            {
                ToCaps();
            }
        }

        private void w_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("w");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("W");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("W");
            }
            else
            {
                SendKeys.Send("w");
            }
        }

        private void e_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("e");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("E");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("E");
            }
            else
            {
                SendKeys.Send("e");
            }
        }

        private void r_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("r");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("R");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("R");
            }
            else
            {
                SendKeys.Send("r");
            }
        }

        private void t_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("t");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("T");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("T");
            }
            else
            {
                SendKeys.Send("t");
            }
        }

        private void y_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("y");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("Y");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("Y");
            }
            else
            {
                SendKeys.Send("y");
            }
        }

        private void u_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("u");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("U");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("U");
            }
            else
            {
                SendKeys.Send("u");
            }
        }

        private void i_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("i");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("I");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("I");
            }
            else
            {
                SendKeys.Send("i");
            }
        }

        private void o_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("o");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("O");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("O");
            }
            else
            {
                SendKeys.Send("o");
            }
        }

        private void p_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("p");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("P");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("P");
            }
            else
            {
                SendKeys.Send("p");
            }
        }

        private void openBrackets_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("{");
            }
            else
            {
                SendKeys.Send("[");
            }
        }

        private void closingBrackets_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("}");
            }
            else
            {
                SendKeys.Send("]");
            }
        }

        private void backslash_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("|");
            }
            else
            {
                SendKeys.Send("\\");
            }
        }

        private void a_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("a");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("A");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("A");
            }
            else
            {
                SendKeys.Send("a");
            }
        }

        private void s_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("s");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("S");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("S");
            }
            else
            {
                SendKeys.Send("s");
            }
        }

        private void d_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("d");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("D");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("D");
            }
            else
            {
                SendKeys.Send("d");
            }
        }

        private void f_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("f");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("F");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("F");
            }
            else
            {
                SendKeys.Send("f");
            }
        }

        private void g_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("g");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("G");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("G");
            }
            else
            {
                SendKeys.Send("g");
            }
        }

        private void h_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("h");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("H");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("H");
            }
            else
            {
                SendKeys.Send("h");
            }
        }

        private void j_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("j");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("J");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("J");
            }
            else
            {
                SendKeys.Send("j");
            }
        }

        private void k_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("k");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("K");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("K");
            }
            else
            {
                SendKeys.Send("k");
            }
        }

        private void l_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("l");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("L");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("L");
            }
            else
            {
                SendKeys.Send("l");
            }
        }

        private void semiColon_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send(":");
                FromShift();
            }
            else
            {
                SendKeys.Send(";");
            }
        }

        private void z_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("z");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("Z");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("Z");
            }
            else
            {
                SendKeys.Send("z");
            }
        }

        private void x_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("x");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("X");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("X");
            }
            else
            {
                SendKeys.Send("x");
            }
        }

        private void c_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("c");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("C");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("C");
            }
            else
            {
                SendKeys.Send("c");
            }
        }

        private void v_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("v");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("V");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("V");
            }
            else
            {
                SendKeys.Send("v");
            }
        }

        private void b_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("b");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("B");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("B");
            }
            else
            {
                SendKeys.Send("b");
            }
        }

        private void n_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("n");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("N");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("N");
            }
            else
            {
                SendKeys.Send("n");
            }
        }

        private void m_Click(object sender, EventArgs e)
        {
            if (ShiftDown && CapsDown)
            {
                SendKeys.Send("m");
                FromShift();
            }
            else if (ShiftDown && !CapsDown)
            {
                SendKeys.Send("M");
                FromShift();
            }
            else if (!ShiftDown && CapsDown)
            {
                SendKeys.Send("M");
            }
            else
            {
                SendKeys.Send("m");
            }
        }

        private void apostrophe_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("\"");
                FromShift();
            }
            else
            {
                SendKeys.Send("'");
            }
        }

        private void forewardSlash_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("?");
                FromShift();
            }
            else
            {
                SendKeys.Send("/");
            }
        }

        private void period_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send(">");
                FromShift();
            }
            else
            {
                SendKeys.Send(".");
            }
        }

        private void comma_Click(object sender, EventArgs e)
        {
            if (ShiftDown)
            {
                SendKeys.Send("<");
                FromShift();
            }
            else
            {
                SendKeys.Send(",");
            }
        }

        private void space_Click(object sender, EventArgs e)
        {
            SendKeys.Send(" ");
        }

        private void enter_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{ENTER}");
        }

        private void upArrow_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{UP}");
        }

        private void downArrow_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{DOWN}");
        }

        private void leftArrow_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{LEFT}");
        }

        private void rightArrow_Click(object sender, EventArgs e)
        {
            SendKeys.Send("{RIGHT}");
        }

        private void VirtualKeybaoard_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawImage(DrawingArea, 0, 0, DrawingArea.Width, DrawingArea.Height);

        }

       
    }
}

